<template>
  <div>
    <app-header v-if="bNav"></app-header>
    <!-- 展示区 router-view -->
    <Nuxt />
  </div>
</template>
<script>
import AppHeader from './app-header'
export default {
  // middleware: 'auth',//页面层级中间件定义 定义到外部的方式
  middleware({store,route,redirect,params,query,req,res}){
    // console.log("middleware  layouts");
     //context服务端上下文信息
    //全局守卫业务
        //store 状态树上的信息
        //一条目标路由的信息
        //redirect方法做路由强制跳转
        //params ， query 校验参数合理性
    // console.log("middleware 已加载 layouts  全局守卫前置业务");
    // redirect('/reg');
  },
  data(){
    return{
      bNav:true
    }
  },
  watch:{
    $route:{
      immediate:true,
      handler(route){
        if(/login|reg/.test(route.path)){
          this.bNav=false;
        }else{
          this.bNav=true;
        }
      }
    }
  },
  components:{AppHeader}
}
</script>
<style>
html {
  font-family:
    'Source Sans Pro',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial,
    sans-serif;
  font-size: 16px;
  word-spacing: 1px;
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}

.button--green {
  display: inline-block;
  border-radius: 4px;
  border: 1px solid #3b8070;
  color: #3b8070;
  text-decoration: none;
  padding: 10px 30px;
}

.button--green:hover {
  color: #fff;
  background-color: #3b8070;
}

.button--grey {
  display: inline-block;
  border-radius: 4px;
  border: 1px solid #35495e;
  color: #35495e;
  text-decoration: none;
  padding: 10px 30px;
  margin-left: 15px;
}

.button--grey:hover {
  color: #fff;
  background-color: #35495e;
}
</style>
